import { HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { RequestService } from './request.service';
import { Injectable } from '@angular/core';
import { CommonApi } from './commonApi';
import { Overview } from '../model/statitistics';

@Injectable()
export class StatisticsService {

  private baseUrl = '/statistic';
  constructor(
    private request: RequestService
  ) { }

  public fetchOverview(date: Date): Observable<Overview> {
    const url = this.baseUrl + '/overview';
    const param = new HttpParams(
      { fromObject: { date: date.toISOString() } }
    );
    return this.request.get(url, param);
  }
}
